
function isOkCon(ipAddress, path, method) {
	$.messager.progress({title: "提示", msg: "正在检测数据库连接..", interval: 1000});
	$.ajax({
		url : path + "/con/isOk.do",
		type : "post",
		dataType : "text",
		data : {
			ipAddress : ipAddress
		},
		success : function(data, textStatus, jqXHR) {
			//console.log("状态码: " + jqXHR.status + "===" + textStatus);
			$.messager.progress('close');
			if (data == "gsmappConFalse") {
				$.messager.alert("提示", "与" + ipAddress + "连接超时,请重试!", "error");
			} else if (data == "162ptConFalse") {
				$.messager.alert("提示", "与中心平台连接超时,请重试!", "error");
			} else if (data == "162testConFalse") {
				$.messager.alert("提示", "与中转站连接超时,请重试!", "error");
			} else if (data == "gsmcenterConFalse") {
				$.messager.alert("提示", "与北分中心连接超时,请重试!", "error");
			} else {
				eval(method);
			}
		},
		error:function(){
			$.messager.progress('close');
			$.messager.alert("提示", "数据库连接失败,请检查网络和IP地址!", "error");
		},
		complete:function(){
	 		
	 	}
	});
}

/**
 * session超时检测,全局的ajax方法,每个ajax请求都会触发该操作
 * 
 * */
$(document).ajaxSend(function(event, jqxhr, settings) {
	var path = getWebRootPath();
	var url = settings.url;
	//console.log(url + "====");
	if(url.indexOf("isSessionTimeOut.do") == -1){
		$.ajax({
			url: path + "con/isSessionTimeOut.do",
			type: "post",
			dataType: "json",
			success: function(data){
				if(data){
					$.messager.alert("提示","session超时, 请重新登陆!", "info");
					var url = window.parent.location.href + "login.jsp";
					window.setTimeout(
							function(){
								window.parent.location.href = url;
									},1000);
				}
			},
			error: function(){
				$.messager.alert("提示","session检测出现异常!", "error");
			}
		});
	}
});

/**
 * 返回结果:http://localhost:8080/jhys-web-tools/
 * */
function getWebRootPath(){
	var allPath = window.parent.location.href;
	var webAppName = window.parent.location.pathname;
	var p = allPath.indexOf(webAppName);
	var localHostPath = allPath.substring(0, p);
	return localHostPath + webAppName;
}




